import type { AxiosRequestConfig, AxiosResponse } from 'axios';
import type { RequestOptions } from './types';

export interface CreateAxiosOptions extends AxiosRequestConfig {
  authenticationScheme?: string;
  transform?: AxiosTransform;
  requestOptions?: RequestOptions;
}

export abstract class AxiosTransform {
  
  beforeRequestHook?: (config: AxiosRequestConfig, options: RequestOptions) => AxiosRequestConfig;
  
  transformResponseHook?: (res: AxiosResponse & any, options: RequestOptions) => any;
  
  requestCatchHook?: (e: Error, options: RequestOptions) => Promise<any>;
  
  requestInterceptors?: (config: AxiosRequestConfig,
    options: CreateAxiosOptions) => AxiosRequestConfig;
  
  responseInterceptors?: (res: AxiosResponse<any>) => AxiosResponse<any>;
  
  requestInterceptorsCatch?: (error: Error) => void;
  
  responseInterceptorsCatch?: (axiosInstance: AxiosResponse, error: Error) => void;
}
